<template>
  <a-card :bordered="false">


    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus"style="margin-left: 10px;margin-bottom: 2px" >新增</a-button>
    </div>
    <div>
      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="userId"
        :pagination="ipagination"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a style="color: #ED3F14">删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <a-modal v-model="visible" :width="600" title="title" centered="true" @ok="handleOk">
      <a-form layout="inline" :form="form">
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="参数型号" hasFeedback>
              <a-input style="width: 195px" placeholder="请输入参数型号" v-decorator="['gateway', {}]" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="睫毛上下值" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue1" :min="-1" :max="1" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue1" :min="-1" :max="1"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="睫 毛 长 短" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue2" :min="0" :max="1" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue2" :min="0" :max="1"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="口 红 羽 化" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue3" :min="0.1" :max="2" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue3" :min="0.1" :max="2"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="美 瞳 大 小" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue4" :min="0" :max="1" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue4" :min="0" :max="1"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="眼 影 亮 度" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue5" :min="1" :max="20" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue5" :min="1" :max="20"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="美 颜 程 度" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue6" :min="0" :max="1" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue6" :min="0" :max="1"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="美 白 程 度" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue7" :min="2" :max="10" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue7" :min="2" :max="10"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="眉 毛 缩 放" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue8" :min="0.1" :max="0.5" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue8" :min="0.1" :max="0.5"  :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="width: 100%;padding-top: 20px;">
          <a-col  :span="18" :offset="6">
            <a-form-item  label="眉 毛 拉 伸" hasFeedback>
              <a-row>
                <a-col :span="12">
                  <a-slider v-model="inputValue9" :min="0" :max="0.5" :step="0.01" style="width:100px" />
                </a-col>
                <a-col :span="12">
                  <a-input-number v-model="inputValue9" :min="0" :max="0.5" :step="0.01" style="marginLeft: 16px" />
                </a-col>
              </a-row>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-modal>
  </a-card>
</template>

<script>
import { getAction } from '@/api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'

export default {
  name: "machineParameter",
  mixins: [JeecgListMixin],
  components: {
  },
  data() {
    return {
      visible: false,
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      inputValue1: 0.00,
      inputValue2: 0.12,
      inputValue3: 0.12,
      inputValue4: 0.23,
      inputValue5: 3.50,
      inputValue6: 0.32,
      inputValue7: 2.00,
      inputValue8: 0.25,
      inputValue9: 0.15,
      innerData: [],
      expandedRowKeys: [],
      id: ' ',
      description: '列表展开子表Demo',
      // 列表表头
      columns: [{
        title: '#',
        dataIndex: '',
        key: 'rowIndex',
        width: 60,
        align: "center",
        customRender: function (t, r, index) {
          return parseInt(index) + 1;
        }
      },
        {
          title: '参数型号',
          align: "center",
          dataIndex: 'orderCode'
        },
        {
          title: '睫毛上下值',
          align: "center",
          dataIndex: 'ctype',
          customRender: (text) => {
            let re = "";
            if (text === '1') {
              re = "国内订单";
            } else if (text === '2') {
              re = "国际订单";
            }
            return re;
          }
        },
        {
          title: '睫毛长短',
          align: "center",
          dataIndex: 'orderDate'
        },
        {
          title: '口红羽化',
          align: "center",
          dataIndex: 'orderMoney'
        },
        {
          title: '美瞳大小',
          align: "center",
          dataIndex: 'content'
        },{
          title: '眼影亮度',
          align: "center",
          dataIndex: 'content'
        },{
          title: '美颜程度',
          align: "center",
          dataIndex: 'content'
        },{
          title: '美白程度',
          align: "center",
          dataIndex: 'content'
        },{
          title: '眉毛缩放',
          align: "center",
          dataIndex: 'content'
        },{
          title: '眉毛拉伸',
          align: "center",
          dataIndex: 'content'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: {customRender: 'action'},
        }],
      // 分页参数
      type: "radio",
      url: {
        list: "/test/order/orderList",
        delete: "/test/order/delete",
        deleteBatch: "/test/order/deleteBatch",
        customerListByMainId: "/test/order/listOrderCustomerByMainId",
      },
    }
  },
  computed: {
    currentId(){
      return this.id;
    }
  },
  methods: {
    handleExpand(expanded, record){
      this.expandedRowKeys=[];
      this.innerData=[];
      if(expanded===true){
        this.loading = true;
        this.expandedRowKeys.push(record.id);
        getAction(this.url.customerListByMainId, {mainId: record.id}).then((res) => {
          if (res.success) {
            this.loading = false;
            this.innerData = res.result.records;
          }
        });
      }
    },
    handleAdd() {
      this.visible = true;
    },
    handleEdit(record) {
      this.visible = true;
    },
    showModal() {
      this.visible = true;
    },
    handleOk(e) {
      console.log(e);
      this.visible = false;
    },
  }
}
</script>
<style scoped>
.ant-card-body  {
  margin-bottom: 18px;
}

.table-operator {
  margin-bottom: 0px;
}

.ant-table-tbody .ant-table-row td {
  padding-top: 15px;
  padding-bottom: 15px;
}

.anty-row-operator button {
  margin: 0 5px
}

.ant-btn-danger {
  background-color: #ffffff
}

.ant-modal-cust-warp {
  height: 100%
}

.ant-modal-cust-warp .ant-modal-body {
  height: calc(100% - 110px) !important;
  overflow-y: auto
}

.ant-modal-cust-warp .ant-modal-content {
  height: 90% !important;
  overflow-y: hidden
}
</style>